﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using cfg = System.Configuration;
using GoldPrinter;
using WeifenLuo.WinFormsUI.Docking;
namespace BYManageInfoSystem
{
    public partial class Frm_DispatchCarSheet : DockContent
    {
        private DGBY.BLL.JZXQRTab m_bllJZXQRTab = new DGBY.BLL.JZXQRTab();
        private DGBY.BLL.PaidanRegisterTab m_bllPaidanRegisterTab = new DGBY.BLL.PaidanRegisterTab();
        private DGBY.BLL.T_ACL_User m_bllT_ACL_User = new DGBY.BLL.T_ACL_User();
        private DGBY.BLL.PaiCheTab m_bllPaiCheTab = new DGBY.BLL.PaiCheTab();
        private DGBY.BLL.FactoryDataTab m_bllFactoryDataTab = new DGBY.BLL.FactoryDataTab();
        private DGBY.BLL.FacAddrTab m_bllFacAddrTab = new DGBY.BLL.FacAddrTab();
        private DGBY.BLL.FacConPeoAndTelTab m_bllFacConPeoAndTelTab = new DGBY.BLL.FacConPeoAndTelTab();
        private DGBY.BLL.TCCompDataTab m_bllTCCompDataTab = new DGBY.BLL.TCCompDataTab();
        private DGBY.BLL.TCCompConPeoTelTab m_bllTCCompConPeoTelTab = new DGBY.BLL.TCCompConPeoTelTab();
        private DGBY.BLL.PaiCheZGMXTab m_bllPaiCheZGMXTab = new DGBY.BLL.PaiCheZGMXTab();
        private DGBY.BLL.PortTab m_bllPortTab = new DGBY.BLL.PortTab();
        private DGBY.BLL.GuiXingTab m_bllGuiXingTab = new DGBY.BLL.GuiXingTab();
        private DGBY.BLL.BYCompanyTab m_bllBYCompanyTab = new DGBY.BLL.BYCompanyTab();

        private int m_nSelectPaiCheZGMXTabID = 0;
        //private string m_strContractNo = "";
        //private string m_strDJNo = "";


        private int m_nSelectPaiCheTabID = 0;
        
        string m_strQueryWhere = "";
        protected string templetFilePath = cfg.ConfigurationSettings.AppSettings["TempletFilePath"];
        //ExcelBase eB = new ExcelBase();
        public Frm_DispatchCarSheet()
        {
            InitializeComponent();
        }

        private void InitCombox()
        {
            DataSet ds = m_bllBYCompanyTab.GetList("");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                this.comboBoxComp.DataSource = ds.Tables[0];
                this.comboBoxComp.DisplayMember = "经营单位名称";
                this.comboBoxComp.ValueMember = "BYCompanyTabID";
                this.comboBoxComp.SelectedIndex = 0;
            }
            ds = m_bllFactoryDataTab.GetList("");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                this.comboBoxFac.DataSource = ds.Tables[0];

                this.comboBoxFac.ValueMember = "FactoryDataTabID";
                this.comboBoxFac.DisplayMember = "工厂简称";
                this.comboBoxFac.AutoCompleteSource = AutoCompleteSource.ListItems;
                this.comboBoxFac.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
                this.comboBoxFac.SelectedIndex = 0;
            }
            ds = m_bllT_ACL_User.GetList("Name != 'System1'");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                this.comboBoxContactP.DataSource = ds.Tables[0];
                this.comboBoxContactP.DisplayMember = "用户名称";
                this.comboBoxContactP.ValueMember = "UserPasswordTabID";
                this.comboBoxContactP.SelectedValue = Frm_Main.m_nLoginUserId; 
            }

            ds = m_bllTCCompDataTab.GetList("");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                this.comboBoxTrailerCompName.DataSource = ds.Tables[0];
                this.comboBoxTrailerCompName.DisplayMember = "拖车公司名称";
                this.comboBoxTrailerCompName.ValueMember = "TCCompDataTabID";
                this.comboBoxTrailerCompName.SelectedIndex = 0;
            }
            ds = m_bllPortTab.GetList("");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                this.comboBoxGetBoxPlace.DataSource = ds.Tables[0];
                this.comboBoxGetBoxPlace.DisplayMember = "港口名称";
                this.comboBoxGetBoxPlace.ValueMember = "PortTabID";
                this.comboBoxGetBoxPlace.SelectedIndex = 0;
            }
            ds = m_bllGuiXingTab.GetList("");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                this.comboBoxBoxType.DataSource = ds.Tables[0];
                this.comboBoxBoxType.DisplayMember = "柜型";
                this.comboBoxBoxType.ValueMember = "GuiXingTabID";
                this.comboBoxBoxType.SelectedIndex = 0;
            }
            ds = m_bllFacAddrTab.GetList("");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                this.comboBoxFacAddr.DataSource = ds.Tables[0];
                this.comboBoxFacAddr.DisplayMember = "FacAddr";
                this.comboBoxFacAddr.ValueMember = "FacAddrTabID";
                this.comboBoxFacAddr.SelectedIndex = 0;
            }
            ds = m_bllFacConPeoAndTelTab.GetList("");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                this.comboBoxFacConP.DataSource = ds.Tables[0];
                this.comboBoxFacConP.DisplayMember = "FacConPeoName";
                this.comboBoxFacConP.ValueMember = "FacConPeoAndTelTabID";
                this.comboBoxFacConP.SelectedIndex = 0;
            }
           
        }
        private void ShowAllMXRecordInDataGridView(string PaiCheDJNo)
        {

            //this.textBoxFillBoxContractNo.Text = "";
            this.textBoxFillBoxSheetNo.Text = this.textBoxSheetNo.Text;
            DataSet ds = m_bllPaiCheZGMXTab.ShowAllZGMX("PaiCheTab.PaiCheDJNo = '" + PaiCheDJNo + "'");
            ultraGrid2.DataSource = null;

            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                ultraGrid2.DataSource = ds.Tables[0];
                ultraGrid2.DisplayLayout.Bands[0].Columns[0].Hidden = true;
                ultraGrid2.DisplayLayout.Bands[0].Columns[1].Hidden = true;
            }
            //SetSumFields(strContractCode);
        }
        private void Frm_DispatchCarSheet_Load(object sender, EventArgs e)
        {
            
            InitCombox();

        }
        private void InitFactoryCombox(string strFacName)
        {
            DataSet ds = m_bllFactoryDataTab.GetList("FactoryName = '" + strFacName + "'");
            int nFacId = 0;
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                nFacId = Convert.ToInt32(ds.Tables[0].Rows[0]["FactoryDataTabID"].ToString(), 10);
            }
            ds = m_bllFacAddrTab.GetList("FactoryDataTabID = '" + nFacId + "'");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                this.comboBoxFacAddr.DataSource = ds.Tables[0];
                this.comboBoxFacAddr.DisplayMember = "FacAddr";
                this.comboBoxFacAddr.ValueMember = "FacAddrTabID";
                this.comboBoxFacAddr.SelectedIndex = 0;
            }
            ds = m_bllFacConPeoAndTelTab.GetList("FactoryDataTabID = '" + nFacId + "'");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                this.comboBoxFacConP.DataSource = ds.Tables[0];
                this.comboBoxFacConP.DisplayMember = "FacConPeoName";
                this.comboBoxFacConP.ValueMember = "FacConPeoAndTelTabID";
                this.comboBoxFacConP.SelectedIndex = 0;
            }
        }

        private void comboBoxComp_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                string str = this.comboBoxComp.SelectedValue.ToString();
                int nID = Convert.ToInt32(str, 10);
                DataSet ds = m_bllBYCompanyTab.GetList("BYCompanyTabID = '" + nID.ToString() + "'");
                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    this.textBoxSelfCompFax.Text = ds.Tables[0].Rows[0]["传真"].ToString();
                    this.textBoxSelfCompPhone.Text = ds.Tables[0].Rows[0]["电话"].ToString();
                }
            }
            catch { }
 
        }
        private void comboBoxFac_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                string str = this.comboBoxFac.SelectedValue.ToString();
                int nFacId = Convert.ToInt32(str, 10);
                DataSet ds = m_bllFactoryDataTab.GetList("FactoryDataTabID = '" + nFacId + "'");
                
                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    this.textBoxFacTel.Text = ds.Tables[0].Rows[0]["工厂电话"].ToString();
                    this.textBoxFacFax.Text = ds.Tables[0].Rows[0]["工厂传真"].ToString();
                    ds = m_bllFacAddrTab.GetList("FactoryDataTabID = '" + nFacId + "'");
                    if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                    {
                        this.comboBoxFacAddr.DataSource = ds.Tables[0];
                        this.comboBoxFacAddr.DisplayMember = "FacAddr";
                        this.comboBoxFacAddr.ValueMember = "FacAddrTabID";
                        this.comboBoxFacAddr.SelectedIndex = 0;
                    }
                    ds = m_bllFacConPeoAndTelTab.GetList("FactoryDataTabID = '" + nFacId + "'");
                    if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                    {
                        this.comboBoxFacConP.DataSource = ds.Tables[0];
                        this.comboBoxFacConP.DisplayMember = "FacConPeoName";
                        this.comboBoxFacConP.ValueMember = "FacConPeoAndTelTabID";
                        this.comboBoxFacConP.SelectedIndex = 0;
                    }


                }


            }
            catch { }
        }
        private void comboBoxContractNo_SelectedIndexChanged(object sender, EventArgs e)
        {
            //try
            //{
            //    string str = this.comboBoxDJNo.SelectedValue.ToString();
            //    int nID = Convert.ToInt32(str, 10);

            //    DataSet ds = m_bllPaidanRegisterTab.GetList("PaidanRegisterTabID = '" + nID + "'");
            //    string strContractCode = ds.Tables[0].Rows[0]["ContractCode"].ToString();
            //    DataSet ds2 = m_bllPaiCheTab.GetJYCompNameEtc("ContractCode = '" + strContractCode + "'");
            //    if (ds2.Tables.Count > 0 && ds2.Tables[0].Rows.Count > 0)
            //    {
            //        this.textBoxSelfComp.Text = ds2.Tables[0].Rows[0]["需方名称"].ToString();
            //        this.textBoxSelfCompFax.Text = ds2.Tables[0].Rows[0]["需方传真"].ToString();
            //        this.textBoxSelfCompPhone.Text = ds2.Tables[0].Rows[0]["需方电话"].ToString();
            //    }

            //    ds2 = m_bllPaiCheTab.GetFacNameEtc("ContractCode = '" + strContractCode + "'");
            //    if (ds2.Tables.Count > 0 && ds2.Tables[0].Rows.Count > 0)
            //    {
            //        this.textBoxFacName.Text = ds2.Tables[0].Rows[0]["工厂名称"].ToString();
            //        this.textBoxFacTel.Text = ds2.Tables[0].Rows[0]["工厂电话"].ToString();
            //        this.textBoxFacFax.Text = ds2.Tables[0].Rows[0]["工厂传真"].ToString();
            //    }

            //    InitFactoryCombox(this.textBoxFacName.Text);
            //    ShowPaicheSheetByContractCode(strContractCode);
            //}
            //catch { }
        }

        private void comboBoxFacConP_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                string str = this.comboBoxFacConP.SelectedValue.ToString();
                int nID = Convert.ToInt32(str, 10);

                DataSet ds = m_bllFacConPeoAndTelTab.GetList("FacConPeoAndTelTabID = '" + nID + "'");
                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    this.textBoxFacCpmPTel.Text = ds.Tables[0].Rows[0]["FacConPeoTel"].ToString();
                }
            }
            catch { }
        }

        private void comboBoxTrailerCompName_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                string str = this.comboBoxTrailerCompName.SelectedValue.ToString();
                int nID = Convert.ToInt32(str, 10);

                DataSet ds = m_bllTCCompDataTab.GetList("TCCompDataTabID = '" + nID + "'");
                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    this.textBoxTrailerTel.Text = ds.Tables[0].Rows[0]["拖车公司电话"].ToString();
                    this.textBoxTrailerFax.Text = ds.Tables[0].Rows[0]["拖车公司传真"].ToString();
                }
                this.comboBoxTrailerConP.DataSource = null;
                nID = Convert.ToInt32(ds.Tables[0].Rows[0]["TCCompDataTabID"].ToString(), 10);
                ds = m_bllTCCompConPeoTelTab.GetList("TCCompDataTabID = '" + nID + "'");
                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    this.comboBoxTrailerConP.DataSource = ds.Tables[0];
                    this.comboBoxTrailerConP.DisplayMember = "TCCompConPeoName";
                    this.comboBoxTrailerConP.ValueMember = "TCCompConPeoTelTabID";
                    this.comboBoxTrailerConP.SelectedIndex = 0;
                }
            }
            catch { }
        }



        //private void ShowPaicheSheetByContractCode(string strContractCode)
        //{

        //    DataSet ds = m_bllPaiCheTab.ShowAllPCDRecByHTCode("PaidanRegisterTab.ContractCode = '" + strContractCode + "'");

        //    ultraGrid1.DataSource = null;
        //    ultraGrid2.DataSource = null;
        //    if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
        //    {
        //        string strDjNo = ds.Tables[0].Rows[0]["单据号"].ToString();
        //        ultraGrid1.DataSource = ds.Tables[0];
        //        ultraGrid1.DisplayLayout.Bands[0].Columns[0].Hidden = true;
        //        ShowAllMXRecordInDataGridView(strDjNo);
        //    }
            
        //}
        private void ShowAllRecordInDataGridView(string strWhere)
        {
            ultraGrid1.DataSource = null;
            DataSet ds = m_bllPaiCheTab.ShowAllPCDRecByHTCode(strWhere);
            ultraGrid1.DataSource = null;

            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                ultraGrid1.DataSource = ds.Tables[0];
                ultraGrid1.DisplayLayout.Bands[0].Columns[0].Hidden = true;
            }
        }

        private void buttonShowAll_Click(object sender, EventArgs e)
        {
            ShowAllRecordInDataGridView("");
            this.ultraGrid1.Dock = DockStyle.Fill;
            this.groupBoxGoodsDetail.Visible = false;
        }

       

        private void cellPaiCheTabClick()
        {
          //  this.textBoxFillBoxContractNo.Text = "";
            
            this.ultraGrid1.Dock = DockStyle.None;
            this.groupBoxGoodsDetail.Visible = true;
            DGBY.Model.PaiCheTab modelPaiCheTab = m_bllPaiCheTab.GetModel(m_nSelectPaiCheTabID);
            if (modelPaiCheTab != null)
            {
                this.textBoxSheetNo.Text = modelPaiCheTab.PaiCheDJNo.ToString();
                this.textBoxFillBoxSheetNo.Text = modelPaiCheTab.PaiCheDJNo.ToString();
                this.textBoxNote.Text = modelPaiCheTab.Note;
                this.textBoxDjNo.Text = modelPaiCheTab.PaiCheDJNo.ToString();
                //if (modelPaiCheTab.PaidanRegisterTabID != null)
                //    this.comboBoxDJNo.SelectedValue = modelPaiCheTab.PaidanRegisterTabID;
                if (modelPaiCheTab.UserPasswordTabID != null)
                    this.comboBoxContactP.SelectedValue = modelPaiCheTab.UserPasswordTabID;
                if (modelPaiCheTab.FacAddrTabID != null)
                    this.comboBoxFacAddr.SelectedValue = modelPaiCheTab.FacAddrTabID;
                if (modelPaiCheTab.FacConPeoAndTelTabID != null)
                    this.comboBoxFacConP.SelectedValue = modelPaiCheTab.FacConPeoAndTelTabID;
                if (modelPaiCheTab.TCCompConPeoTelTabID != null)
                {
                    DataSet ds = m_bllTCCompConPeoTelTab.GetList("TCCompConPeoTelTabID = '" + modelPaiCheTab.TCCompConPeoTelTabID + "'");
                    if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                    {
                        this.comboBoxTrailerCompName.SelectedValue = Convert.ToInt32(ds.Tables[0].Rows[0]["TCCompDataTabID"].ToString(), 10);
                    }
                    this.comboBoxTrailerConP.SelectedValue = modelPaiCheTab.TCCompConPeoTelTabID;
                }
                ShowAllMXRecordInDataGridView(this.textBoxFillBoxSheetNo.Text);
            }

        }


        private Int64 MakeSJPackDJNo()
        {
            string strDate = System.DateTime.Now.Year.ToString() + System.DateTime.Now.Month.ToString().PadLeft(2, '0') + System.DateTime.Now.Day.ToString().PadLeft(2, '0');
            DataSet ds = m_bllPaiCheTab.GetSJPackDJNoByDate("PaiCheDJDate = '" + strDate + "'");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                string strDJNo = ds.Tables[0].Rows[0]["MaxJPackDJNum"].ToString();
                long nDJNo = 0;
                if (strDJNo != "")
                    nDJNo = Convert.ToInt64(strDJNo, 10);
                nDJNo++;
                string strTemp = "";
                if (strDJNo != "")
                    strTemp = string.Format("{0:d4}", nDJNo);
                else
                    strTemp = strDate + string.Format("{0:d4}", nDJNo);

                return Convert.ToInt64(strTemp, 10);
            }

            return 0;
        }
        private void buttonAddDisCarSheet_Click(object sender, EventArgs e)
        {
            try
            {
                //DataSet ds = m_bllPaiCheTab.ShowAllPCDRecByHTCode("ContractCode = '" + "" + "'");


                //if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                //{
                //    MessageBox.Show("该合同编号已有对应的派车单了!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //    return;
                //}

                DGBY.Model.PaiCheTab modelPaiCheTab = new DGBY.Model.PaiCheTab();


                modelPaiCheTab.PaiCheDJNo = MakeSJPackDJNo();
                modelPaiCheTab.Note = this.textBoxNote.Text;
                modelPaiCheTab.PaiCheDJDate = System.DateTime.Now.Date;

                //if (this.comboBoxDJNo.SelectedValue != null)
                //    modelPaiCheTab.PaidanRegisterTabID = Convert.ToInt32(this.comboBoxDJNo.SelectedValue.ToString(), 10);
                if (this.comboBoxContactP.SelectedValue != null)
                    modelPaiCheTab.UserPasswordTabID = Convert.ToInt32(this.comboBoxContactP.SelectedValue.ToString(), 10);
                if (this.comboBoxFacAddr.SelectedValue != null)
                    modelPaiCheTab.FacAddrTabID = Convert.ToInt32(this.comboBoxFacAddr.SelectedValue.ToString(), 10);
                if (this.comboBoxFacConP.SelectedValue != null)
                    modelPaiCheTab.FacConPeoAndTelTabID = Convert.ToInt32(this.comboBoxFacConP.SelectedValue.ToString(), 10);
                if (this.comboBoxTrailerConP.SelectedValue != null)
                    modelPaiCheTab.TCCompConPeoTelTabID = Convert.ToInt32(this.comboBoxTrailerConP.SelectedValue.ToString(), 10);

                m_bllPaiCheTab.Add(modelPaiCheTab);
                this.textBoxDjNo.Text = modelPaiCheTab.PaiCheDJNo.ToString();
                ShowAllRecordInDataGridView("PaiCheDJNo = '" + this.textBoxDjNo.Text + "'");
                //MessageBox.Show("数据添加成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
       
        }

        private void buttonModifyDisCarSheet_Click(object sender, EventArgs e)
        {
            try
            {
                DGBY.Model.PaiCheTab modelPaiCheTabOld = m_bllPaiCheTab.GetModel(m_nSelectPaiCheTabID);
                if (modelPaiCheTabOld == null)
                {
                    MessageBox.Show("数据库不存在该记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

               // DGBY.Model.PaiCheTab modelPaiCheTab = new DGBY.Model.PaiCheTab();
               // modelPaiCheTab.PaiCheTabID = m_nSelectPaiCheTabID;
                //modelPaiCheTabOld.PaiCheDJNo = modelPaiCheTabOld.PaiCheDJNo;

                modelPaiCheTabOld.Note = this.textBoxNote.Text;
              //  modelPaiCheTabOld.PaiCheDJDate = modelPaiCheTabOld.PaiCheDJDate;

                //if (this.comboBoxDJNo.SelectedValue != null)
                //    modelPaiCheTab.PaidanRegisterTabID = Convert.ToInt32(this.comboBoxDJNo.SelectedValue.ToString(), 10);
                if (this.comboBoxContactP.SelectedValue != null)
                    modelPaiCheTabOld.UserPasswordTabID = Convert.ToInt32(this.comboBoxContactP.SelectedValue.ToString(), 10);
                if (this.comboBoxFacAddr.SelectedValue != null)
                    modelPaiCheTabOld.FacAddrTabID = Convert.ToInt32(this.comboBoxFacAddr.SelectedValue.ToString(), 10);
                if (this.comboBoxFacConP.SelectedValue != null)
                    modelPaiCheTabOld.FacConPeoAndTelTabID = Convert.ToInt32(this.comboBoxFacConP.SelectedValue.ToString(), 10);
                if (this.comboBoxTrailerConP.SelectedValue != null)
                    modelPaiCheTabOld.TCCompConPeoTelTabID = Convert.ToInt32(this.comboBoxTrailerConP.SelectedValue.ToString(), 10);

                m_bllPaiCheTab.Update(modelPaiCheTabOld);
                ShowAllRecordInDataGridView("PaiCheDJNo = '" + this.textBoxDjNo.Text + "'");
                //ShowPaicheSheetByContractCode("");
                MessageBox.Show("数据修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
           
        }

        private void buttonDelDisCarSheet_Click(object sender, EventArgs e)
        {
            if (m_bllPaiCheTab.GetModel(m_nSelectPaiCheTabID) == null)
            {
                MessageBox.Show("数据库不存在该记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (MessageBox.Show("确实要删除该条记录!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
            {
                m_bllPaiCheTab.Delete(m_nSelectPaiCheTabID);

                ShowAllRecordInDataGridView("");
                MessageBox.Show("数据删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

                this.textBoxSheetNo.Text = "";
                this.textBoxNote.Text = "";
                this.textBoxFillBoxSheetNo.Text = "";
                
                return;
            }
        }

        

      

        private void buttonCopySheetNo_Click(object sender, EventArgs e)
        {
            //DataSet ds = m_bllPaiCheTab.ShowAllPCDRecByHTCode("ContractCode = '" + "" + "'");


            //if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            //{
            //    MessageBox.Show("该合同编号已有对应的派车单了，因此无法复制单据，请重新选择合同编号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //    return;
            //}

            DataSet ds = m_bllPaiCheTab.ShowAllPCDRecByHTCode("PaiCheDJNo = '" + this.textBoxSheetNo.Text + "'");

            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                //int nPaidanRegisterTabID = 0;
                DateTime dt = System.DateTime.Now.Date;
                Int64 n64NewDJNo = MakeSJPackDJNo();
               // DataSet dsTemp = m_bllPaidanRegisterTab.GetAllPaiDanList("ContractCode = '" + "" + "'");
               // if (dsTemp.Tables.Count > 0 && dsTemp.Tables[0].Rows.Count > 0)
                {
                 //   nPaidanRegisterTabID = Convert.ToInt32(dsTemp.Tables[0].Rows[0]["PaidanRegisterTabID"].ToString(), 10);
                    ds = m_bllFactoryDataTab.GetList("FactoryName = '" + this.comboBoxFac.Text + "'");
                    int nFacId = 0;
                    if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                    {
                        nFacId = Convert.ToInt32(ds.Tables[0].Rows[0]["FactoryDataTabID"].ToString(), 10);
                    }
                    ds = m_bllFacAddrTab.GetList("FactoryDataTabID = '" + nFacId + "'");
                    string strFacAddrTabID = "";
                    if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                    {
                        strFacAddrTabID = ds.Tables[0].Rows[0]["FacAddrTabID"].ToString();
                    }
                    ds = m_bllFacConPeoAndTelTab.GetList("FactoryDataTabID = '" + nFacId + "'");
                    string strFacConPeoAndTelTabID = "";
                    if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                    {
                        strFacConPeoAndTelTabID = ds.Tables[0].Rows[0]["FacConPeoAndTelTabID"].ToString();
                    }

                    m_bllPaiCheTab.CopyDJNo(dt, n64NewDJNo, Convert.ToInt64(this.textBoxSheetNo.Text, 10), strFacAddrTabID, strFacConPeoAndTelTabID);
                    string strNewPaiCheTabID = "";
                    DataSet dsTemp2 = m_bllPaiCheTab.ShowAllPCDRecByHTCode("PaiCheDJNo = '" + n64NewDJNo.ToString() + "'");
                    if (dsTemp2.Tables.Count > 0 && dsTemp2.Tables[0].Rows.Count > 0)
                    {
                        strNewPaiCheTabID = dsTemp2.Tables[0].Rows[0]["PaiCheTabID"].ToString();
                        m_bllPaiCheTab.CopyDJNoForMXGoods(strNewPaiCheTabID, Convert.ToInt64(this.textBoxSheetNo.Text, 10));
                    }
                    ShowAllRecordInDataGridView("PaiCheDJNo = '" + n64NewDJNo.ToString() + "'");
                    //ShowPaicheSheetByContractCode("");
                }
            }
            else
            {
                MessageBox.Show("该单据号没有对应的派车单记录，因此无法复制单据，请重新输入单据号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
        }

        
        private void buttonExportToExcel_Click(object sender, EventArgs e)
        {
            DataSet ds = m_bllPaiCheZGMXTab.ShowAllZGMX("PaiCheTab.PaiCheDJNo = '" + this.textBoxSheetNo.Text + "'");
            DataTable dt = ds.Tables[0];
            //DataTable dt = (DataTable)dataGridViewFillBoxList.DataSource;
            ds = m_bllPaiCheTab.ShowAllPCDRecByHTCode("PaiCheDJNo = '" + this.textBoxSheetNo.Text + "'");
            DataTable dt1 = ds.Tables[0];
            if (dt1 != null)
            {
                if (dt1.Rows.Count > 1)
                {
                    MessageBox.Show("请选择不多于一条派车单记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
            else
            {
                MessageBox.Show("派车单记录不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (dt != null)
            {
                if (dt.Rows.Count > 0)
                {
                    SaveFileDialog sfd = new SaveFileDialog();
                    sfd.Filter = "Excel文件(*.xls)|*.xls";
                    string outFile = "";

                    if (sfd.ShowDialog() == DialogResult.OK)
                    {
                        outFile = sfd.FileName;
                    }
                    else
                    {
                        return;
                    }

                    string templetFile = templetFilePath + "派车单.xlt";

                    ExcelBase eB = new ExcelBase(templetFile, outFile);

                    try
                    {
                        eB.DispachCar_DataTableToExcel(dt, dt1, 10, 14, 1, "页", 2);
                    }
                    catch (System.Exception ex)
                    {

                    }

                    eB.Close();
                }
            }
            else
            {
                MessageBox.Show("装箱单明细不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }

        private void buttonPrintPreview_Click(object sender, EventArgs e)
        {
            DataSet ds1 = m_bllPaiCheZGMXTab.ShowAllZGMX("PaiCheTab.PaiCheDJNo = '" + this.textBoxSheetNo.Text + "'");
            DataTable dt = ds1.Tables[0];
            //DataTable dt = (DataTable)dataGridViewFillBoxList.DataSource;
            DataSet ds = m_bllPaiCheTab.ShowAllPCDRecByHTCode("PaiCheDJNo = '" + this.textBoxSheetNo.Text + "'");
            DataTable dt1 = ds.Tables[0];
            if (dt1 != null)
            {
                if (dt1.Rows.Count > 1)
                {
                    MessageBox.Show("请选择不多于一条派车单记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
            else
            {
                MessageBox.Show("派车单记录不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (dt != null)
            {
                if (dt.Rows.Count > 0)
                {
                    string templetFile = templetFilePath + "派车单.xlt";
                    string outFile = "";
                    ExcelBase eB = new ExcelBase(templetFile, outFile);

                    try
                    {
                        eB.DispachCar_DataTableToExcelAndPrintPreview(dt, dt1, 10, 14, 1, "页", 2);
                    }
                    catch (System.Exception ex)
                    {

                    }


                }
            }
            else
            {
                MessageBox.Show("派车单明细不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }

        private void buttonPrint_Click(object sender, EventArgs e)
        {
            DataSet ds = m_bllPaiCheZGMXTab.ShowAllZGMX("PaiCheTab.PaiCheDJNo = '" + this.textBoxSheetNo.Text + "'");
            DataTable dt = ds.Tables[0];
            //DataTable dt = (DataTable)dataGridViewFillBoxList.DataSource;
            ds = m_bllPaiCheTab.ShowAllPCDRecByHTCode("PaiCheDJNo = '" + this.textBoxSheetNo.Text + "'");
            DataTable dt1 = ds.Tables[0];
            if (dt1 != null)
            {
                if (dt1.Rows.Count > 1)
                {
                    MessageBox.Show("请选择不多于一条派车单记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
            else
            {
                MessageBox.Show("派车单记录不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (dt != null)
            {
                if (dt.Rows.Count > 0)
                {
                    string templetFile = templetFilePath + "派车单.xlt";
                    string outFile = "";
                    ExcelBase eB = new ExcelBase(templetFile, outFile);

                    try
                    {
                        eB.DispachCar_DataTableToExcelAndPrint(dt, dt1, 10, 14, 1, "页", 2);
                    }
                    catch (System.Exception ex)
                    {

                    }

                    eB.Close();
                }
            }
            else
            {
                MessageBox.Show("派车单明细不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }

        private void Frm_DispatchCarSheet_FormClosing(object sender, FormClosingEventArgs e)
        {
            //eB.Close();
        }

        //private void buttonDetailShow_Click(object sender, EventArgs e)
        //{
        //    int nSelectSJPackingTabID = 0;
        //    //if (dataGridViewDisCarSheetList.Rows.Count > 0)
        //    //{
        //    //    string strSJPackingTabID = this.dataGridViewDisCarSheetList.Rows[this.dataGridViewDisCarSheetList.CurrentCell.RowIndex].Cells[0].Value.ToString();
        //    //    nSelectSJPackingTabID = Convert.ToInt32(strSJPackingTabID, 10);
        //    //}

        //    string strNewPaiCheTabID = "";
        //    DataSet dsTemp2 = m_bllPaiCheTab.ShowAllPCDRecByHTCode("ContractCode = '" + this.comboBoxContractNo.Text + "'");
        //    if (dsTemp2.Tables.Count > 0 && dsTemp2.Tables[0].Rows.Count > 0)
        //    {
        //        strNewPaiCheTabID = dsTemp2.Tables[0].Rows[0]["PaiCheTabID"].ToString();
        //        nSelectSJPackingTabID = Convert.ToInt32(strNewPaiCheTabID, 10);
        //        //m_bllPaiCheTab.CopyDJNoForMXGoods(strNewPaiCheTabID, Convert.ToInt64(this.textBoxSheetNo.Text, 10));
        //    }
        //    Frm_DispatchCarSheetDetail frm_DispatchCarSheetDetail = new Frm_DispatchCarSheetDetail(this.comboBoxContractNo.Text, m_strDJNo);
        //    frm_DispatchCarSheetDetail.StartPosition = FormStartPosition.CenterScreen;
        //    frm_DispatchCarSheetDetail.ShowDialog();
        //}

        private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
        {
            ClassUltraGridCommonSet.ultraGrid1_InitializeRowFilter(e);
        }

        private void ultraGrid1_AfterCellActivate(object sender, EventArgs e)
        {
            int iIndex = this.ultraGrid1.ActiveCell.Row.Index;
            if (iIndex < 0)
                return;
            string strPaiCheTabID = this.ultraGrid1.Rows[this.ultraGrid1.ActiveCell.Row.Index].Cells[0].Text;
            m_nSelectPaiCheTabID = Convert.ToInt32(strPaiCheTabID, 10);
            cellPaiCheTabClick();
        }
        //private void dataGridViewDisCarSheetList_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        //{
        //    string strPaiCheTabID = this.dataGridViewDisCarSheetList.Rows[this.dataGridViewDisCarSheetList.CurrentCell.RowIndex].Cells[0].Value.ToString();
        //    m_strDJNo = this.dataGridViewDisCarSheetList.Rows[this.dataGridViewDisCarSheetList.CurrentCell.RowIndex].Cells[1].Value.ToString();
        //    int nOldID = m_nSelectPaiCheTabID;
        //    m_nSelectPaiCheTabID = Convert.ToInt32(strPaiCheTabID, 10);
        //    if (nOldID != m_nSelectPaiCheTabID)
        //    {
        //        DataSet ds = m_bllPaiCheTab.ShowAllPCDRecByHTCode("PaidanRegisterTab.ContractCode = '" + this.comboBoxContractNo.Text + "'"
        //                                                        + "and PaiCheDJNo = '" + this.textBoxSheetNo.Text + "'");

        //        if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
        //        {
        //            dataGridViewDisCarSheetList.DataSource = ds.Tables[0];
        //            dataGridViewDisCarSheetList.Columns[0].Visible = false;

        //        }
        //    }
        //    cellPaiCheTabClick();
        //}
        private void ultraGrid2_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
        {
            ClassUltraGridCommonSet.ultraGrid1_InitializeRowFilter(e);
        }

        private void ultraGrid2_AfterCellActivate(object sender, EventArgs e)
        {
            int iIndex = this.ultraGrid2.ActiveCell.Row.Index;
            if (iIndex < 0)
                return;
            string strPaiCheZGMXTabID = this.ultraGrid2.Rows[this.ultraGrid2.ActiveCell.Row.Index].Cells[0].Text;
            m_nSelectPaiCheZGMXTabID = Convert.ToInt32(strPaiCheZGMXTabID, 10);
            cellPaiCheZGMXTabClick();
        }
       

        private void cellPaiCheZGMXTabClick()
        {
            DGBY.Model.PaiCheZGMXTab modelPaiCheZGMXTab = m_bllPaiCheZGMXTab.GetModel(m_nSelectPaiCheZGMXTabID);
            if (modelPaiCheZGMXTab != null)
            {
                this.textBoxCabinSeatReserveNo.Text = modelPaiCheZGMXTab.DingCangNo;
                this.dateTimePickerFillBoxDate.Value = (System.DateTime)modelPaiCheZGMXTab.TGDate;
                string[] sArray = modelPaiCheZGMXTab.TGTime.Split(':');
                this.textBoxFillBoxHour.Text = sArray[0];
                this.textBoxFillBoxMin.Text = sArray[1];
                this.textBoxBoxNum.Text = modelPaiCheZGMXTab.GuiNumber.ToString();

                if (modelPaiCheZGMXTab.PortTabID != null)
                    this.comboBoxGetBoxPlace.SelectedValue = modelPaiCheZGMXTab.PortTabID;
                if (modelPaiCheZGMXTab.GuiXingTabID != null)
                    this.comboBoxBoxType.SelectedValue = modelPaiCheZGMXTab.GuiXingTabID;
            }

        }
        private Int64 MakeBoxConfirmDJNo()
        {
            string strDate = System.DateTime.Now.Year.ToString() + System.DateTime.Now.Month.ToString().PadLeft(2, '0') + System.DateTime.Now.Day.ToString().PadLeft(2, '0');
            DataSet ds = m_bllJZXQRTab.GetSJPackDJNoByDate("JZXQRDJDate = '" + strDate + "'");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                string strDJNo = ds.Tables[0].Rows[0]["MaxJPackDJNum"].ToString();
                long nDJNo = 0;
                if (strDJNo != "")
                    nDJNo = Convert.ToInt64(strDJNo, 10);
                nDJNo++;
                string strTemp = "";
                if (strDJNo != "")
                    strTemp = string.Format("{0:d4}", nDJNo);
                else
                    strTemp = strDate + string.Format("{0:d4}", nDJNo);

                return Convert.ToInt64(strTemp, 10);
            }

            return 0;
        }

        private void AddBoxConfirm(int nPaiCheTabID, DateTime dt, string strHourMin)
        {
            try
            {
                DGBY.Model.JZXQRTab modelJZXQRTab = new DGBY.Model.JZXQRTab();


                modelJZXQRTab.JZXQRDJNo = MakeBoxConfirmDJNo();
                modelJZXQRTab.PaiCheTabID = nPaiCheTabID;
                modelJZXQRTab.JZXQRDJDate = System.DateTime.Now.Date;
                modelJZXQRTab.ShipCompName = "";
                modelJZXQRTab.DingDanNo = "";
                modelJZXQRTab.Note = "";

                modelJZXQRTab.YuTiGuiDate = System.DateTime.Now.Date; ;
                modelJZXQRTab.TiGuiDate = dt;
                modelJZXQRTab.ZGWCDate = System.DateTime.Now.Date; ;
                modelJZXQRTab.JieGuanDate = System.DateTime.Now.Date; ;
                modelJZXQRTab.ArriveFacDate = System.DateTime.Now.Date; ;
                modelJZXQRTab.GoFacDate = System.DateTime.Now.Date; ;

                modelJZXQRTab.YuTiGuiTime = "0:0";
                modelJZXQRTab.TiGuiTime = strHourMin;
                modelJZXQRTab.ZGWCTime = "0:0";
                modelJZXQRTab.JieGuanTime = "0:0";
                modelJZXQRTab.ArriveFacTime = "0:0";
                modelJZXQRTab.GoFacTime = "0:0";

                modelJZXQRTab.DingCangNo = this.textBoxCabinSeatReserveNo.Text;
                modelJZXQRTab.GuiNo = "";
                modelJZXQRTab.FengTiaoNo = "";
                modelJZXQRTab.SJName = "";
                modelJZXQRTab.SJMobile = "";
                modelJZXQRTab.CarPaiNo = "";

                modelJZXQRTab.GuoBangWeight = 0;



                modelJZXQRTab.JGPosTabID = 1;
                if (this.comboBoxGetBoxPlace.SelectedValue != null)
                    modelJZXQRTab.PortTabID = Convert.ToInt32(this.comboBoxGetBoxPlace.SelectedValue.ToString(), 10);
                if (this.comboBoxBoxType.SelectedValue != null)
                    modelJZXQRTab.GuiXingTabID = Convert.ToInt32(this.comboBoxBoxType.SelectedValue.ToString(), 10);
                m_bllJZXQRTab.Add(modelJZXQRTab);

                //  ShowAllRecordInDataGridView("PaidanRegisterTab.PaidanRegisterTabID = '" + modelJZXQRTab.PaidanRegisterTabID + "'");
                //MessageBox.Show("数据添加成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }

        }

        private void buttonAddFillBox_Click(object sender, EventArgs e)
        {
            try
            {
                DGBY.Model.PaiCheZGMXTab modelPaiCheZGMXTab = new DGBY.Model.PaiCheZGMXTab();

                modelPaiCheZGMXTab.DingCangNo = this.textBoxCabinSeatReserveNo.Text;
                modelPaiCheZGMXTab.TGDate = this.dateTimePickerFillBoxDate.Value.Date;
                modelPaiCheZGMXTab.TGTime = this.textBoxFillBoxHour.Text + ":" + this.textBoxFillBoxMin.Text;
                modelPaiCheZGMXTab.GuiNumber = Convert.ToInt32(this.textBoxBoxNum.Text, 10);
                DataSet ds = m_bllPaiCheTab.ShowAllPCDRecByHTCode("PaiCheTab.PaiCheDJNo = '" + this.textBoxFillBoxSheetNo.Text + "'");
                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    modelPaiCheZGMXTab.PaiCheTabID = Convert.ToInt32(ds.Tables[0].Rows[0]["PaiCheTabID"].ToString(), 10);
                }

                if (this.comboBoxGetBoxPlace.SelectedValue != null)
                    modelPaiCheZGMXTab.PortTabID = Convert.ToInt32(this.comboBoxGetBoxPlace.SelectedValue.ToString(), 10);
                if (this.comboBoxBoxType.SelectedValue != null)
                    modelPaiCheZGMXTab.GuiXingTabID = Convert.ToInt32(this.comboBoxBoxType.SelectedValue.ToString(), 10);

                ds = m_bllPaiCheZGMXTab.GetZGMXItemNo("PaiCheDJNo=" + this.textBoxFillBoxSheetNo.Text);
                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    string strMAXItmeNo = ds.Tables[0].Rows[0]["MAXItmeNo"].ToString();
                    if (strMAXItmeNo != "")
                        modelPaiCheZGMXTab.ItmeNo = Convert.ToInt32(strMAXItmeNo, 10) + 1;
                    else
                        modelPaiCheZGMXTab.ItmeNo = 1;
                }
                m_bllPaiCheZGMXTab.Add(modelPaiCheZGMXTab);
                AddBoxConfirm(modelPaiCheZGMXTab.PaiCheTabID, modelPaiCheZGMXTab.TGDate,modelPaiCheZGMXTab.TGTime);
                ShowAllMXRecordInDataGridView(this.textBoxFillBoxSheetNo.Text);
                //MessageBox.Show("数据添加成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
        }

        private void buttonModFillBox_Click(object sender, EventArgs e)
        {
            try
            {
                DGBY.Model.PaiCheZGMXTab modelPaiCheZGMXTabOld = m_bllPaiCheZGMXTab.GetModel(m_nSelectPaiCheZGMXTabID);
                if (modelPaiCheZGMXTabOld == null)
                {
                    MessageBox.Show("数据库不存在该记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                DGBY.Model.PaiCheZGMXTab modelPaiCheZGMXTab = new DGBY.Model.PaiCheZGMXTab();

                modelPaiCheZGMXTab.PaiCheZGMXTabID = m_nSelectPaiCheZGMXTabID;
                modelPaiCheZGMXTab.PaiCheTabID = modelPaiCheZGMXTabOld.PaiCheTabID;
                modelPaiCheZGMXTab.ItmeNo = modelPaiCheZGMXTabOld.ItmeNo;
                modelPaiCheZGMXTab.DingCangNo = this.textBoxCabinSeatReserveNo.Text;
                modelPaiCheZGMXTab.TGDate = this.dateTimePickerFillBoxDate.Value;
                modelPaiCheZGMXTab.TGTime = this.textBoxFillBoxHour.Text + ":" + this.textBoxFillBoxMin.Text;
                modelPaiCheZGMXTab.GuiNumber = Convert.ToInt32(this.textBoxBoxNum.Text, 10);

                if (this.comboBoxGetBoxPlace.SelectedValue != null)
                    modelPaiCheZGMXTab.PortTabID = Convert.ToInt32(this.comboBoxGetBoxPlace.SelectedValue.ToString(), 10);
                if (this.comboBoxBoxType.SelectedValue != null)
                    modelPaiCheZGMXTab.GuiXingTabID = Convert.ToInt32(this.comboBoxBoxType.SelectedValue.ToString(), 10);

                m_bllPaiCheZGMXTab.Update(modelPaiCheZGMXTab);
                ShowAllMXRecordInDataGridView(this.textBoxFillBoxSheetNo.Text);
                MessageBox.Show("数据修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }

        }

        private void buttonDelFillBox_Click(object sender, EventArgs e)
        {
            DGBY.Model.PaiCheZGMXTab modelPaiCheZGMXTabOld = m_bllPaiCheZGMXTab.GetModel(m_nSelectPaiCheZGMXTabID);
            if (modelPaiCheZGMXTabOld == null)
            {
                MessageBox.Show("数据库不存在该记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (MessageBox.Show("确实要删除该条记录!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
            {
                m_bllPaiCheZGMXTab.Delete(m_nSelectPaiCheZGMXTabID);
                this.textBoxCabinSeatReserveNo.Text = "";
                this.textBoxFillBoxHour.Text = "";
                this.textBoxFillBoxMin.Text = "";
                this.textBoxBoxNum.Text = "";
                ShowAllMXRecordInDataGridView(this.textBoxFillBoxSheetNo.Text);
                MessageBox.Show("数据删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
        }

        private void Frm_DispatchCarSheet_Activated(object sender, EventArgs e)
        {
            InitCombox();
        }

        private void Frm_DispatchCarSheet_Deactivate(object sender, EventArgs e)
        {
          //  Frm_Main.m_nContractSelectIndex = this.comboBoxDJNo.SelectedIndex;
        }





    }
}